//
//  CellFirstFindNewSongs.m
//  练习11
//
//  Created by 张琦 on 15/11/21.
//  Copyright © 2015年 张琦. All rights reserved.
//

#import "CellFirstFindNewSongs.h"
#import "CellFirstNewSongsRect.h"
#define SCR_WIDTH     [UIScreen mainScreen].bounds.size.width
#define SCR_HEIGHT    [UIScreen mainScreen].bounds.size.height

@interface CellFirstFindNewSongs ()<UITableViewDataSource, UITableViewDelegate>
@property (nonatomic, retain) UITableView *tableView;
@property (nonatomic, retain) UILabel *labelTitle;
@property (nonatomic, retain) UIView *viewSuper;

@end
@implementation CellFirstFindNewSongs




- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createView];
    }
    return self;
}


- (void)createView
{
    self.viewSuper = [[UIView alloc] init];
    self.viewSuper.backgroundColor = [UIColor lightGrayColor];
    [self.contentView addSubview:self.viewSuper];
    [_viewSuper release];
    
    self.labelTitle = [[UILabel alloc] init];
    self.labelTitle.backgroundColor = [UIColor cyanColor];
    [self.viewSuper addSubview:self.labelTitle];
    [_labelTitle release];
    
    
    
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 0, 0) style:UITableViewStylePlain];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView.scrollEnabled = NO;
    [self.viewSuper addSubview:self.tableView];
    self.tableView.dataSource = self;
    self.tableView.delegate = self;
    [self.tableView registerClass:[CellFirstNewSongsRect class] forCellReuseIdentifier:@"CellFirstNewSongsRect"];
}
- (void)setName:(NSString *)name
{
    if (_name != name) {
        [_name release];
        _name = [name retain];
    }
    self.labelTitle.text = name;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    CellFirstNewSongsRect *cell = [tableView dequeueReusableCellWithIdentifier:@"CellFirstNewSongsRect"];
    cell.dic = [self.array objectAtIndex:indexPath.row];
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 90;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    self.viewSuper.frame = self.contentView.frame;
    self.labelTitle.frame = CGRectMake(0, 5, self.viewSuper.frame.size.width, 35);
    self.tableView.frame = CGRectMake(0, 40, self.contentView.frame.size.width, self.contentView.frame.size.height - 40 - 5);
    
    
}


@end
